#!/bin/sh

BASEDIR="`dirname "${0}"`/.."
. "${BASEDIR}/functions"

RTPA_SUBDR="rtp_analyze"

for i in 1 4 25 82 322
do
  dd if=${RTPA_SUBDR}/alice_srtp.pcap of=rtp_analyze_trunc.pcap bs=1 count=${i} 2>/dev/null
  ${EXTRACTAUDIO} -e -s -n \
   '--alice-crypto=AES_CM_128_HMAC_SHA1_80:9sOd+W72ilwfNgNt0FzlGYj6YZPMqN1sJJx43UuS' \
   -A rtp_analyze_trunc.pcap '--bob-crypto=AES_CM_128_HMAC_SHA1_80:NhqBK/JjtVJgmOgPyDKpvMTEjvFCQ4eiyVQelF6x' \
   -B ${RTPA_SUBDR}/bob_srtp.pcap /dev/null
  reportifnotfail "Truncating alice's stream at ${i} bytes"
  ${EXTRACTAUDIO} -e -s -n \
   '--bob-crypto=AES_CM_128_HMAC_SHA1_80:9sOd+W72ilwfNgNt0FzlGYj6YZPMqN1sJJx43UuS' \
   -B rtp_analyze_trunc.pcap '--alice-crypto=AES_CM_128_HMAC_SHA1_80:NhqBK/JjtVJgmOgPyDKpvMTEjvFCQ4eiyVQelF6x' \
   -A ${RTPA_SUBDR}/bob_srtp.pcap /dev/null
  reportifnotfail "Truncating both's streams at ${i} bytes"
  ${EXTRACTAUDIO} -s -n \
   '--bob-crypto=AES_CM_128_HMAC_SHA1_80:9sOd+W72ilwfNgNt0FzlGYj6YZPMqN1sJJx43UuS' \
   -B rtp_analyze_trunc.pcap '--alice-crypto=AES_CM_128_HMAC_SHA1_80:9sOd+W72ilwfNgNt0FzlGYj6YZPMqN1sJJx43UuS' \
   -A rtp_analyze_trunc.pcap /dev/null
  reportifnotfail "Truncating both's streams at ${i} bytes"
  ${EXTRACTAUDIO} -S \
   '--bob-crypto=AES_CM_128_HMAC_SHA1_80:9sOd+W72ilwfNgNt0FzlGYj6YZPMqN1sJJx43UuS' \
   -B rtp_analyze_trunc.pcap '--alice-crypto=AES_CM_128_HMAC_SHA1_80:9sOd+W72ilwfNgNt0FzlGYj6YZPMqN1sJJx43UuS' \
   -A rtp_analyze_trunc.pcap
  report "Scanning streams truncated at ${i} bytes"
done
